﻿using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Security.Principal;
using IdeaBlade.EntityModel;

namespace CoProjectDF.Models
{

    /// <summary>
    /// Class containing information about the authenticated user.
    /// </summary>
    /// <remarks>
    /// Extends the standard UserBase with profile information, and a helper property.
    /// </remarks>
    [DataContract]
    public partial class User : UserBase
    {

        public User(IIdentity identity, IEnumerable<string> roles)
            : base(identity, roles)
        {
        }

        //// NOTE: Profile properties can be added for use in Silverlight application.
        //// To enable profiles, edit the appropriate section of web.config file.
        ////
        //// public string MyProfileProperty { get; set; }

        /// <summary>
        /// Gets and sets the friendly name of the user.
        /// </summary>
        /// <remarks>
        /// This is a Profile-backed property.
        /// </remarks>
        [DataMember]
        public string FriendlyName { get; set; }


        /// <summary>
        /// Returns the user display name, which by default is its Friendly Name,
        /// and if that is not set, its User Name
        /// </summary>
        public string DisplayName
        {
            get
            {
                if (!string.IsNullOrEmpty(this.FriendlyName))
                {
                    return this.FriendlyName;
                }
                else
                {
                    return this.Name;
                }
            }
        }

    }
}
